﻿using HarmonyLib;
using RimWorld;
using RimWorld.QuestGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SZ.Mech;
using UnityEngine;
using Verse;

[HarmonyPatch(typeof(CompLongRangeMineralScanner), "DoFind")]
public static class CompLongRangeMineralScanner_Patch
{
    private static bool Prefix(CompLongRangeMineralScanner __instance, Pawn worker, ref ThingDef ___targetMineable)
    {

        if (___targetMineable != SZ_DefOf.MineableShenZhuHeJi)
        {
            return true;
        }
        var slate = new Slate();
        slate.Set("map", worker.Map);
        slate.Set("targetMineable", ___targetMineable);
        slate.Set("worker", worker);

        //if (!SZ_DefOf.DanRoomQuest.CanRun(slate))
        //{
        //    return true;
        //}
        

        var quest = QuestUtility.GenerateQuestAndMakeAvailable(SZ_DefOf.DanRoomQuest, slate);
        Find.LetterStack.ReceiveLetter(quest.name.Translate(), quest.description, LetterDefOf.PositiveEvent, null, null, quest);
        return false;
    }
}

